package org.example.partition;

import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.KeyedStream;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;

public class PartitionTest {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironment();

        env.setParallelism(2);


        DataStreamSource<String> localhost = env.socketTextStream("localhost", 8777);


        // 随机分区
//        localhost.shuffle().print();
        // 轮询
//        localhost.rebalance().print();
        // 缩放 局部组队轮询
//        localhost.rescale().print();
        // 广播 每个源数据都给所有的
//        localhost.broadcast().print();

        //全局：全部发送给第一任务
        localhost.global().print();




        env.execute();
    }
}

